<?php
session_start();

if (isset($_POST['comment_text'])) {
    $comment_text = $_POST['comment_text'];
}
if (isset($_POST['forum_id'])) {
    $forum_id = $_POST['forum_id'];
}

if ($comment_text != "" && $forum_id != "") {
    $now = time();

    //get user id from session which is currently logged in user's user id.
    $user_id= $_SESSION['user_id'];
    $parent_id=0;

    mysql_connect("localhost","root","");
    mysql_select_db("susudo");

    $comment_query="INSERT INTO `susudo`.`comment` (`id`, `forum_id`, `user_id`, `comment_text`, `created_at`) VALUES (NULL, '$forum_id','$user_id', '$comment_text', '$now')";
    mysql_query($comment_query);

    mysql_close();

    header("location: ../frontend.php?page=comment&forum=$forum_id");
    //echo "<p style='color:#00f'>Hi, $fullname, thanks for the information. </p> ";


}
else {
    header("location: ../frontend.php?page=forum");
}

;
?>


